﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T17Collection
{
    class Product : IComparable
    {
        private string name;
        private string typeName;

        public string Name { get => name; set => name = value; }
        public string TypeName { get => typeName; set => typeName = value; }

        public Product() { }

        public Product(string name, string typeName)
        {
            this.name = name;
            this.typeName = typeName;
        }

        public override bool Equals(object obj)
        {
            var product = obj as Product;
            return product != null &&
                   name == product.name;
        }

        public override int GetHashCode()
        {
            return 363513814 + EqualityComparer<string>.Default.GetHashCode(name);
        }

        public int CompareTo(object obj)
        {
            return name.CompareTo(((Product)obj).name);
        }
    }
}
